package com.example.yamba;

/**
 * Created by Jagery on 2015-8-18.
 */
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.util.Log;
public class DBHepler extends SQLiteOpenHelper {
    private static final String DB_NAME = "timeline.db";
    private static final int VERSION = 2;
    private static final String TAG = "DBHepler" ;
    private Context context;
    static final String TABLE = "timeline";
    static final String C_ID = BaseColumns._ID;
    static final String C_CREATE_AT = "create_at";
    static final String C_STATUS = "status";
    static final String C_USER = "user";
    public DBHepler (Context context){
        super(context,DB_NAME,null,VERSION);
        this.context = context; 
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table "+TABLE+
                "( "+C_ID+" INTEGER ,"+
                    C_CREATE_AT +" TEXT,"+
                    C_USER+" TEXT,"+
                    C_STATUS+" TEXT)";
        db.execSQL(sql);
        Log.i(TAG,"create table= "+sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists "+TABLE);
        Log.i(TAG,"Upgrade DB");
        onCreate(db);
    }
}
